﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Auction
{
    public partial class FormMainMenu : Form
    {
        private EDM_AuctionContainer context;   
        public FormMainMenu()
        {
            InitializeComponent();
        }

        public FormMainMenu(EDM_AuctionContainer context)
        {
            // TODO: Complete member initialization
            this.context = context;
            InitializeComponent();
        }
       
        public void CloseAll()
        {
            foreach (Control ctr in pnlContainer.Controls)
            {
                if (ctr is Form)
                {
                    ((Form)ctr).Close();
                }
            }
        }

        private void ShowForm(Form frm)//o form base
        {
            CloseAll();
            frm.TopLevel = false;
            this.pnlContainer.Controls.Add(frm);
            frm.Show();
        }

        private void pnlContainer_Paint(object sender, PaintEventArgs e)
        {

        }

     
    
        private void FormMainMenu_Load(object sender, EventArgs e)
        {

        }

        private void eXITToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void addBidderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FBidders fbidders = new FBidders(FBidders.ACTION.CREATE, context);
            ShowForm(fbidders);
        }

        private void searchBidderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FBidders f_bidder = new FBidders(FBidders.ACTION.SEARCH, context);
            ShowForm(f_bidder);
        }

        private void addBondToBidderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FBidders f_bidder = new FBidders(FBidders.ACTION.ADDBOND, context);
            ShowForm(f_bidder);
        }

        private void deleteBidderToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FBidders f_bidder = new FBidders(FBidders.ACTION.DELETE, context);
            ShowForm(f_bidder);
        }

        private void modifyBidderToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            FBidders f_bidder = new FBidders(FBidders.ACTION.MODIFY, context);
            ShowForm(f_bidder);
        }

        private void createNewWorkOfArtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FWorkOfArt fwork = new FWorkOfArt(FWorkOfArt.ACTION.CREATE, context);
            ShowForm(fwork);
        }

        private void searchWorkOfArtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FWorkOfArt fwork = new FWorkOfArt(FWorkOfArt.ACTION.SEARCH, context);
            ShowForm(fwork);
        }

        private void modifyWorkOfArtToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FWorkOfArt fwork = new FWorkOfArt(FWorkOfArt.ACTION.MODIFY,context);
            ShowForm(fwork);
        }

        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FWorkOfArt fwork = new FWorkOfArt(FWorkOfArt.ACTION.DELETE,context);
            ShowForm(fwork);
        }

        private void deletePackageToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            FPackage fpackage = new FPackage(FPackage.ACTION.DELETE, context);
            ShowForm(fpackage);
        }

        private void createPackageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FPackage fpackage = new FPackage(FPackage.ACTION.CREATE,context);
            ShowForm(fpackage);
        }

        private void searchPackageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FPackage fpackage = new FPackage(FPackage.ACTION.SEARCH,context);
            ShowForm(fpackage);
        }

        private void addWorksToPackageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FPackage fpackage = new FPackage(FPackage.ACTION.ADDWORK,context);
            ShowForm(fpackage);
        }

        private void modifyPackageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FPackage fpackage = new FPackage(FPackage.ACTION.MODIFY,context);
            ShowForm(fpackage);
        }

        private void newAuctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            FAuction fauction = new FAuction(FAuction.ACTION.CREATE,context);
           ShowForm(fauction);
        }

        private void modifyAuctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FAuction fauction = new FAuction(FAuction.ACTION.MODIFY,context);
            ShowForm(fauction);
        }
        private void searchAuctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FAuction fauction = new FAuction(FAuction.ACTION.SEARCH, context);
            ShowForm(fauction);
        }

        private void activeAuctionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FAuction fauction = new FAuction(FAuction.ACTION.ACTIVE, context);
            ShowForm(fauction);
        }

        private void bid1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bidder bidder = context.BidderSet.FirstOrDefault(c => c.idBidder == 1);
            ClientForm clientform = new ClientForm(context,bidder);
            ShowForm(clientform);
        }
    }
}
